#include "Message.h"
#include <sstream>

using namespace std;

Message::Message()
{
    ServiceId.Value = 0;

    mAttributes.push_back(&ServiceId);
    mAttributes.push_back(&Length);
    //mAttributes.insert(make_pair("Newline" , NULL));
    mAttributes.push_back(&UserAgent);
    mAttributes.push_back(&UserToken);
    mAttributes.push_back(&TargetId);
}

void Message::ParseMessage(std::string pMessage) {
    mRawMessage = pMessage;
    istringstream stream(pMessage);

    for (vector<MessageAttribute*>::iterator it = mAttributes.begin() ; it != mAttributes.end() ; it++) {
        if (stream.eof()) { ///Supposedly not eof here, right?
            throw exception();
        }

        if (*it == NULL) {

        }
        else {
            (*it)->ReadValue(stream);
        }
    }
}

std::string Message::ToString() {

}

Message::~Message()
{
    //dtor
}
